#include <iostream>
#include "IGoodsPlugin.h"
#include <unistd.h> //read(file)
#include <fcntl.h>
#include <string.h>
using namespace std;



objMask::objMask()
{
	m_id = 2;
	m_price = 2;
	m_stock = 10;
	m_name = (char*)"面膜";
}

objMask::~objMask()
{
}

void objMask::Print()
{
	cout << m_name << "业务信息: " << endl;
	cout << "价格: " << m_price << endl;
	cout << "库存: " << m_stock << endl;
}

void objMask::PrintInfo()
{
	// cout << "Class ID " << m_id << " : This Class will provide the information about the price and stock of mask." << endl;
	// cout << "price: "<< m_price << endl;
	// cout << "stock:" << m_stock << endl;
	// cout << "name:" << FUNC_NAME << endl;
	cout << m_id << '\t' << m_name << '\t' << m_price << '\t' << m_stock << endl;
}

int objMask::GetID(void)
{
	return m_id;
}

char *objMask::GetName()
{
	return m_name;
}

bool objMask::GetType(int &type)
{
	type = m_id;
	return true;
}

bool objMask::Serialize(FILE *fp)
{
	if (fp == NULL)
		return false;
	fwrite(&m_id, sizeof(int), 1, fp);
	fwrite(&m_price, sizeof(int), 1, fp);
	fwrite(&m_stock, sizeof(int), 1, fp);
	return true;
}

IGoodsPlugin *objMask::Deserialize(FILE *fp)
{
	objMask *p = new objMask();
	fread(&(p->m_id), sizeof(int), 1, fp);
	fread(&(p->m_price), sizeof(int), 1, fp);
	fread(&(p->m_stock), sizeof(int), 1, fp);
	return p;
}

